<script>
	const baseurl = 'https://www.lichu2025.cn'
	import Vue from 'vue';
	export default {
		globalData: {
			baseurl: baseurl,
			post(url, data, toast = true, method = 'POST') {
				return new Promise((success, fail) => {
					if (toast) {
						uni.showLoading({
							title: '加载中'
						})
					}
					uni.request({
						url: baseurl + url,
						method,
						header: {
							'token': uni.getStorageSync('wanlshop:user').token,
						},
						data: {
							...data
						},
						success: res => {
							if (res.res.code == 1) {
								success(res.data)
							} else {
								uni.showToast({
									title: res.data.msg,
									icon: "none"
								})
								fail(res.data)
							}
						},
						fail: res => {
							fail(res.data)
						},
						complete: () => {
							uni.hideLoading()
						}
					})
				})
			},

		},
		onLaunch() {
			// 检测客户端更新
			this.$store.dispatch('update/update');
			// 仅首次打开一次性加载数据
			this.$store.dispatch('common/init');
			// 同步购物车 本地 & 网络
			this.$store.dispatch('cart/get');
			// 同步 动态数据
			this.$store.dispatch('statistics/get');

			// this.$store.dispatch('seele/loadPageConf',{});

			// this.$store.dispatch('seele/initShopQrCode',15);
		},
		onShow() {
			// 启动或重启即时通讯 
			// TODO 调试时候临时关闭
			// this.$store.dispatch('chat/connectSocket');
		},
		onHide() {
			// 断开即时通讯
			this.$store.dispatch('chat/close');
		}
	};
</script>

<style>
	/* #ifndef APP-NVUE */
	@import 'static/style/colorui.css';
	@import 'static/style/wanlshop.css';
	@import 'static/style/iconfont.css';
	/* #endif */

	@import "/css/pages.css";
	@import "/css/display.css";

	page {
		background-color: #F7F7F7;
	}

	.chufangyao {
		filter: blur(4px);
	}

	.lc-null {
		width: 750rpx;
		height: 30rpx;
	}

	.lc-big {
		width: 750rpx;
		height: 170rpx;
	}
</style>